package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.ConsultationRecord;
import com.zzyl.entity.Contract;
import com.zzyl.mapper.ConsultationRecordMapper;
import com.zzyl.service.ConsultationRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RequiredArgsConstructor
public class ConsultationRecordServiceImpl implements ConsultationRecordService {

    private  final ConsultationRecordMapper mapper;


    /**
     * 查询退住咨询
     * @param name
     * @param phone
     * @param type
     * @param pageNum
     * @param pageSize
     * @return
     */
    public PageResponse<ConsultationRecord> query(String name, String phone, Integer type, Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum, pageSize);

        Page<List<ConsultationRecord>> page = mapper.selectPage(name, phone, type);

        return PageResponse.of(page, ConsultationRecord.class);
    }

    /**
     * 新增咨询
     * @param consultationRecord
     */
    public void add(ConsultationRecord consultationRecord) {
        mapper.insert(consultationRecord);
    }
}
